<?php
require '../model/Db.php';
$Db = Db::getInstance();
$admin_data = $Db->isadmin();
if($admin_data){
	$msg = '你已经登录了哦,请不要再重复登录啦~';
	$class = 'err';
	$reurl = 'admin.php';
	include './view/skip.html';
	exit();
}
if(isset($_POST['submit'])){
	$_POST = $Db->escape($_POST);
	$exist = $Db->find([
		table => ['bbs_manager'],
		where => "user = '{$_POST['admin']}' and pwd = sha1(md5('{$_POST['pwd']}'))"
	]);
	$Db->close();
	if($exist){
		setcookie('M_',md5($_POST['admin']));
		setcookie('_W',sha1(md5($_POST['pwd'])));
	}
	$msg = $exist?'登录成功啦~青柠后台欢迎您！':'登陆失败,账号密码错误！';
	$class = $exist?'ok':'err';
	$reurl = $exist?'admin.php':'';
	include './view/skip.html';
}else{
	$css = ['../public/css/admin-reg.css'];
	include './view/login.html';
}
	